#pragma once
#ifndef _I_REQUEST_H_

#define _I_REQUEST_H_

#include "HTTPMethod.h"
#include <string>


/*抽象请求接口*/
class AbstractIRequest
{
public:
	inline AbstractIRequest() {}
	virtual ~AbstractIRequest() {};

	/* 访问属性 */
	virtual void* getConnectionId() = 0;
	virtual unsigned long getTotalRecvBytes() = 0;
	virtual HTTPMethod method() = 0;
	virtual std::string uri(bool decode) = 0;
	virtual std::string field(const char* key) = 0;
	virtual bool keepAlive() = 0;
	virtual bool range(__int64 &from, __int64 &to) = 0;
	virtual bool isValid() = 0;
	virtual unsigned long  headerSize() = 0;
	virtual unsigned long  size() = 0;
	virtual unsigned long  contentLength() = 0;
	virtual __int64 startTime() = 0;

	/* 返回请求头 */
	virtual std::string getHeader() = 0;

	/* 读取 POST DATA */
	virtual size_t read(unsigned char * buf, size_t len) = 0;
	virtual bool eof() = 0;

	/* 控制运行 */
	virtual int run(void * connId, void* clientSock, unsigned long timeout) = 0;
	virtual bool stop(int ec) = 0;
	virtual bool reset() = 0;
private:
	AbstractIRequest(const AbstractIRequest &);

	AbstractIRequest & operator = (const AbstractIRequest &);

};


#endif // !_I_REQUEST_H_
